import Vue from 'vue'
import VueRouter from 'vue-router'
import HomeView from '../views/HomeView.vue'

Vue.use(VueRouter)

const routes = [{
		path: '/',
		// 别名
		alias:["/index","/main"],
		name: 'home',
		component: HomeView
	},
	{
		path: "/admin",
		name: 'admin',
		component: () => import('../views/admin/AdminView.vue'),
		children: [{
				path: "dash",
				name: "dash",
				component: () => import('../views/admin/DashView.vue'),
			},
			{
				path: "event",
				name: "event",
				component: () => import('../views/admin/EventView.vue'),
			},
			// 如果子path为空，自动跳转（重定向到）dash页面
			{
				path: "",
				redirect: "dash"
			}
		]
	},
	{
		path: "/user",
		name: "user",
		component: () => import('../views/UserView.vue')
	},
	{
		path: "/login",
		name: "login",
		component: () => import('../views/LoginView.vue')
	},
	{
		path: "/produce/:id",
		name: 'produce',
		component: () => import('../views/ProduceView.vue')
	},
	{
		path: '/about',
		name: 'about',
		// route level code-splitting
		// this generates a separate chunk (about.[hash].js) for this route
		// which is lazy-loaded when the route is visited.
		component: () => import( /* webpackChunkName: "about" */ '../views/AboutView.vue')
	},
	// 404 配置path为* 配置在做后面
	{
		path: "*",
		component: () => import('../views/NoMatch.vue')
	}
]

const router = new VueRouter({
	routes
})

export default router
